{template 'common/header-gw'}
<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo url('system/site');}">微信开放平台信息</a></li>
</ul>
<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
	<div class="clearfix">
		<h5 class="page-header">微信开放平台开发信息</h5>
		<div class="alert alert-info">开发信息需开放平台审核通过后才可以看到，填写完后才可以使用授权登录功能</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>是否启用微信公众号登录授权</label>
			<div class="col-sm-9 col-xs-12">
				<label class="radio-inline"><input  type="radio" name="authstate"  value="1" {if $_W['setting']['platform']['authstate']} checked{/if} > 是</label>
				<label class="radio-inline"><input  type="radio" name="authstate"  value="0" {if !$_W['setting']['platform']['authstate']} checked{/if} > 否</label>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>测试登陆授权</label>
			<div class="col-sm-9 col-xs-12">
				<a id="auth" href="{$authurl}"><img src="https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon_button3_2.png" /></a>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>AppID</label>
			<div class="col-sm-9 col-xs-12">
				<input type="text"  name="appid" value="{$_W['setting']['platform']['appid']}" class="form-control">
				<div class="help-block">在微信开放平台注册且审核通过后可以获取到AppId</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>AppSecret</label>
			<div class="col-sm-9 col-xs-12">
				<input type="text"  name="appsecret" value="{$_W['setting']['platform']['appsecret']}" class="form-control">
				<div class="help-block">在微信开放平台注册且审核通过后可以获取到AppSecret</div>
			</div>
		</div>
		<h5 class="page-header">微信开放平台接入配置项</h5>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>登录授权的发起页域名</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" readonly name="" value="{$url['host']}" class="form-control">
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>发起授权页的体验URL</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" readonly name="" value="{$url['host']}{$url['path']}web/index.php?c=account&a=auth&do=test" class="form-control">
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>授权事件接受URL</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" readonly name="" value="{$url['host']}{$url['path']}web/index.php?c=account&a=auth&do=ticket" class="form-control">
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red">公众号消息校验Token</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" name="platform_token" class="form-control" value="{$_W['setting']['platform']['token']}"  />
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
					<span class="input-group-addon" style="cursor:pointer" onclick="tokenGen();">生成新的</span>
				</div>
				<div class="help-block">与公众平台接入设置值一致，必须为英文或者数字，长度为3到32个字符. 请妥善保管, Token 泄露将可能被窃取或篡改平台的操作数据.</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red">公众号消息加解密Key</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text"  name="encodingaeskey" class="form-control" value="{$_W['setting']['platform']['encodingaeskey']}" />
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
					<span class="input-group-addon" style="cursor:pointer" onclick="EncodingAESKeyGen();">生成新的</span>
				</div>
				<div class="help-block">与公众平台接入设置值一致，必须为英文或者数字，长度为43个字符. 请妥善保管, EncodingAESKey 泄露将可能被窃取或篡改平台的操作数据.</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>公众号消息与事件接受URL</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" readonly name="" value="{$url['host']}{$url['path']}api.php?appid=/$APPID$" class="form-control">
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>网页开发域名</label>
			<div class="col-sm-9 col-xs-12">
				<div class="input-group">
					<input type="text" readonly name="" value="{$url['host']}" class="form-control">
					<span class="input-group-addon js-clip" style="cursor:pointer">复制</span>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input name="token" type="hidden" value="{$_W['token']}">
		</div>
	</div>
</form>
<script type="text/javascript">
	function tokenGen() {
		var letters = 'abcdefghijklmnopqrstuvwxyz0123456789';
		var token = '';
		for(var i = 0; i < 32; i++) {
			var j = parseInt(Math.random() * (31 + 1));
			token += letters[j];
		}
		$(':text[name="platform_token"]').val(token);
	}
	function EncodingAESKeyGen() {
		var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
		var token = '';
		for(var i = 0; i < 43; i++) {
			var j = parseInt(Math.random() * 61 + 1);
			token += letters[j];
		}
		$(':text[name="encodingaeskey"]').val(token);
	}
	require(['jquery.zclip'], function(){
		$('.js-clip').each(function(){
			var copy_button = this;
			$(copy_button).zclip({
				path: './resource/components/zclip/ZeroClipboard.swf',
				copy: $(copy_button).prev().val(),
				afterCopy: function(){
					$(copy_button).text('复制成功');
					setTimeout(function(){
						$(copy_button).text('复制');
					}, 2000);
				}
			});
		});
	});
	$('#form1').submit(function() {
		var AppId = $.trim($(':text[name="AppId"]').val());
		var platform_token = $.trim($(':text[name="platform_token"]').val());
		if(!platform_token) {
			util.message('platform_token');
			return false;
		}
		var encodingaeskey = $.trim($(':text[name="encodingaeskey"]').val());
		if(!encodingaeskey) {
			util.message('请填写encodingaeskey');
			return false;
		}
	});
</script>
{template 'common/footer-gw'}